#ifndef __case_pty_kenny_kfjiweiiur89u83r33e3e__
#define __case_pty_kenny_kfjiweiiur89u83r33e3e__

#include <hude/base/log.hpp>
#include <hude/aio/context.hpp>
#include <hude/utils/pty.hpp>

#include "test/test.hpp"

namespace test
{
    using namespace hude::utils;

    //--------------------------------------------------------------------------------
    struct case_pty_t : public hude::test::case_t
    {
        // 测试过程
        bool run() override
        {
            pty_pair_t pp;

            auto cb_entry = [&]()
            {
                auto filter = []( std::vector< uint8_t >& buffer )
                {
                    log_dug( "\t forward buffer{ siz: %u, hex: %s }", buffer.size(), hude::utils::to_hex( buffer ).c_str() );
                };

                auto ret = pp.bind( filter, hude::aio::context_t<>::ctx(), 255U );

                if( ret )
                {
                    log_err( "error: pty_pair_t::boot() == %d", ret );
                } else {
                    log_dug( "pty a{ master: %d, ptsname: %s }", pp.a().native(), pp.a().ptsname() );
                    log_dug( "pty b{ master: %d, ptsname: %s }", pp.b().native(), pp.b().ptsname() );
                }
            };

            auto aio = hude::aio::context_t<>::ctx();

            auto ret = aio->run( cb_entry );

            return ret == 0;
        }
    };

    TEST_CASE_ADD( "pty", case_pty_t, false );

} // namespace test

#endif // __case_pty_kenny_kfjiweiiur89u83r33e3e__

